/**
 *       Copyright (c) 2012 Lukas Zaruba
 *
 *   This file is part of Robot Playground.
 *
 *   Robot Playground is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Robot Playground is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with Robot Playground. If not, see <http://www.gnu.org/licenses/>.
 */
package net.zarubsys.robotplayground.core.program;

import net.zarubsys.robotplayground.core.Environment;

/**
 * IProgram
 * 
 * Implement this interface if you want to provide your own implementation of the programming language.
 * Do not forget to contribute your implementation to the proper extension point.
 * An implementation is expected to provide public non-parametric constructor.
 * See the Developer's Guide for details.
 * 
 * Program is expected to register itself as stop listener in the given environment and react properly to the signal.
 * After stop is called, rest of the environment is closed and continuing in the program execution can cause errors 
 * and other unexpected situations!
 *
 * @author Lukas Zaruba, lukas.zaruba@gmail.com
 */
public interface IProgram<T extends IProgramConfiguration> {
	
	/**
	 * This method is called after the instantiation once the session should start running
	 * This method is executed in the separate thread and all the instruction of the program 
	 * based on the configuration should take place in the iterative fashion.
	 * @param api provides access to the function invocation on modules.
	 * @param configuration an instance of the configuration based on the parameter of the subclass
	 * @param env environment shared between all the objects of the running session.
	 */
	void run(API api, T configuration, Environment env);
	
	/**
	 * @return unique id of this program. Be really unique.
	 */
	String getId();

}

